﻿CREATE PROCEDURE [dbo].[yaf_forum_listall](
                @BoardID INT,
                @UserID  INT)
AS
    BEGIN
        SELECT   b.CategoryID,
                 Category = b.Name,
                 a.ForumID,
                 Forum = a.Name,
                 a.ParentID
        FROM     yaf_Forum a
                 JOIN yaf_Category b
                   ON b.CategoryID = a.CategoryID
                 JOIN yaf_vaccess c
                   ON c.ForumID = a.ForumID
        WHERE    c.UserID = @UserID
        AND b.BoardID = @BoardID
        AND c.ReadAccess > 0
        ORDER BY b.SortOrder,
                 a.SortOrder
    END


